#!/usr/bin/env python
# -*- coding: utf-8 -*-

import redis
import time

if __name__ == '__main__':
    r = redis.Redis(host='localhost',port=26379,password='foo',decode_responses=True)
    for i in range(30):
        try:
            r.ping() # key是"foo" value是"bar" 将键值对存入redis缓存
            exit(0)
        except Exception as e:
            print('Exception:\t', str(e))
            time.sleep(5)
        continue
    raise e
    